/**
 * Copyright 2009 - Morten Udnæs
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package com.javabatch.fileio;
/**
 * Class to describe error find when parsing file.
 * @author eco
 *
 */
public class FieldError {
    /**
     * Indicates field format error.
     */
    public static final int FIELD_FORMAT_ERROR = 1;

    /**
     * Indicates field length error.
     */
    public static final int FIELD_LENGTH_ERROR = 2;

    /**
     * Field with error.
     */
    private Field           field;
    /**
     * Value in the field with error.
     */
    private byte[]          value;

    /**
     * Errorcode describing problem.
     */
    private int             errorCode;
    /**
     * Message describing error.
     */
    private String          message;
    /**
     * Field in error.
     */
    private String          fieldName;

    public FieldError(final Field theField, final byte[] theRecordValue,
            final int theErrorCode, final String theFieldName,
            final String theMessage) {
        this.field = theField;
        this.value = theRecordValue;
        this.errorCode = theErrorCode;
        this.message = theMessage;
        this.fieldName = theFieldName;
    }

    public Field getField() {
        return field;
    }

    public void setField(Field field) {
        this.field = field;
    }

    public byte[] getValue() {
        return value;
    }

    public void setValue(byte[] value) {
        this.value = value;
    }

    public int getErrorCode() {
        return errorCode;
    }

    public void setErrorCode(int errorCode) {
        this.errorCode = errorCode;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getFieldName() {
        return fieldName;
    }

    public void setFieldName(String fieldName) {
        this.fieldName = fieldName;
    }

    public static int getFieldFormatError() {
        return FIELD_FORMAT_ERROR;
    }

    public static int getFieldLengthError() {
        return FIELD_LENGTH_ERROR;
    }
}
